package com.elvt.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.elvt.server.mapper.EmployeeTrainMapper;
import com.elvt.server.pojo.EmployeeTrain;
import com.elvt.server.service.IEmployeeTrainService;
import com.elvt.server.utils.RespPageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 作者：elvt
 * @since 2022-05-21
 */
@Service
public class EmployeeTrainServiceImpl extends ServiceImpl<EmployeeTrainMapper, EmployeeTrain> implements IEmployeeTrainService {
    @Autowired
    private EmployeeTrainMapper employeeTrainMapper;
    @Autowired
    private RespPageUtil respPageUtil;

    /**
     * 分页查询
     * @param currentPage 当前页
     * @param size 分页大小
     * @return
     */
    @Override
    public RespPageUtil findAllEmpTrainByPage(Integer currentPage, Integer size) {
        IPage<EmployeeTrain> page=new Page(currentPage,size);
        IPage<EmployeeTrain> trainByPage = employeeTrainMapper.findAllEmpTrainByPage(page);
        respPageUtil.setTotal(trainByPage.getTotal());
        respPageUtil.setData(trainByPage.getRecords());
        return respPageUtil;
    }
}
